package linked_list

func (l *LinkedNode) Reversal(header *LinkedNode) *LinkedNode {
	var (
		newHeader *LinkedNode
		cur       = header
		next      *LinkedNode
	)
	if header == nil {
		return nil
	}

	for cur != nil {
		next = cur.Next
		cur.Next = newHeader
		newHeader = cur
		cur = next
	}
	return newHeader
}
